home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsmakeprompt / RCS / fsmakeprompt,v < prev    next >
Encoding:
Text File  |  1992-11-05  |  11.3 KB  |  461 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    shirriff:1.2; strict;
  6. comment  @# @;
  7.  
  8.  
  9. 1.2
  10. date     91.05.30.12.12.25;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.07.02.22.27.52;  author jhh;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @added ds5000
  27. @
  28. text
  29. @#!/bin/csh -f
  30. #
  31. #  This is an interactive front-end to the fsmake program.
  32. #
  33. # $Header: /sprite/src/admin/fsmakeprompt/RCS/fsmakeprompt,v 1.1 90/07/02 22:27:52 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  34. #
  35. # Copyright 1989 Regents of the University of California
  36. # Permission to use, copy, modify, and distribute this
  37. # software and its documentation for any purpose and without
  38. # fee is hereby granted, provided that the above copyright
  39. # notice appear in all copies.  The University of California
  40. # makes no representations about the suitability of this
  41. # software for any purpose.  It is provided "as is" without
  42. # express or implied warranty.
  43. #
  44.  
  45. onintr cleanup
  46. while ($#argv)
  47.     switch ($1)
  48.     case "-x":
  49.         set echo
  50.         breaksw
  51.     case "-d":
  52.         set debugFlag
  53.         breaksw
  54.     default:
  55.         echo "Usage: $0 [-x]"
  56.         exit 1
  57.         breaksw
  58.     endsw
  59.     shift
  60. end
  61.  
  62. set fsmake="/sprite/admin.$MACHINE/fsmake"
  63. set device = 
  64. set handsOff="y"
  65. set scsi="y"
  66. set inventGeometry="n"
  67. set disktabGeometry="n"
  68. set disktabPartition="n"
  69. set repartition="n"
  70. set autoAssign="y"
  71. set disktabFile="/etc/disktab"
  72. set numSystems=1
  73. set diskType=""
  74. set hostID=""
  75. set doCopy="n"
  76. set write="n"
  77. set copyName = ( "" "" "" "")
  78. set parts = ( "" "" "" "" "" "" "" "")
  79.  
  80. if ($?debugFlag) then
  81.     set echo
  82. endif
  83. startQuestions:
  84.     echo ""
  85.     echo "Please answer the following questions."
  86.     echo "Default answers are surrounded by ()'s."
  87.     echo "Multiple choices are surrounded by []'s"
  88.  
  89.     while(1)
  90.     echo ""
  91.     echo -n "Prefix of disk devices, eg rsd00 ($device): "
  92.     set answer = $<
  93.     if ("$answer" != "") then
  94.         break
  95.     else
  96.         echo "You must specify a prefix"
  97.     endif
  98.     end
  99.     set device = "$answer"
  100.     set rawDevice="$device"
  101.     while (1)
  102.     echo ""
  103.     echo -n "Does the disk contain any filesystems" \
  104.         "you wish to keep? [yn] ($handsOff): "
  105.     set answer = $<
  106.     if ("$answer" == "" || "$answer" =~ [yn]) break
  107.     echo "Please answer with y or n"
  108.     end
  109.     if ("$answer" != "") set handsOff = "$answer"
  110.  
  111.     while (1)
  112.     echo ""
  113.     echo -n "How many new filesystems do you want to make?" \
  114.         "[1234] ($numSystems): "
  115.     set answer = $<
  116.     if ("$answer" == "" || "$answer" =~ [1234]) break
  117.     echo "Please answer with 1,2,3 or 4"
  118.     end
  119.     if ("$answer" != "") set numSystems = "$answer"
  120.     if ($handsOff == "n") then
  121.     switch($numSystems)
  122.         case "1" 
  123.         set parts = ( 'c' )
  124.         set size = ( 100 )
  125.         breaksw
  126.         case "2"
  127.         set parts = ( 'a' 'g')
  128.         set size = ( 25 75 )
  129.         breaksw
  130.         case "3"
  131.         set parts = ( 'a' 'd' 'e')
  132.         set size = ( 34 33 33 )
  133.         breaksw
  134.         case "4"
  135.         set parts = ( 'a' 'd' 'e' 'f' )
  136.         set size = ( 25 25 25 25 )
  137.         breaksw
  138.     endsw
  139.     echo ""
  140.     echo "The filesystems will be made in partitions <$parts>"
  141.     while (1)
  142.         echo -n "Is this OK? [yn] ($autoAssign): "
  143.         set answer = $<
  144.         if ("$answer" == "" || "$answer" =~ [yn]) break
  145.         echo "Please answer with y or n"
  146.     end
  147.     if ("$answer" != "") set autoAssign="$answer"
  148.     else
  149.     set autoAssign="n"
  150.     endif
  151.     if ($autoAssign == "n") then
  152.     set i=1
  153.     while ($i <= $numSystems)
  154.         while(1)
  155.         echo ""
  156.         echo -n "Which partition should filesystem" \
  157.             "$i be made in? [abcdefg] ($parts[$i]): "
  158.         set answer = $<
  159.         if ("$answer" == "" || "$answer" =~ [abcdefg]) break
  160.         echo "Please answer with one of [abcdefg]"
  161.         end
  162.         if ("$answer" != "") set parts[$i] = "$answer"
  163.         @@ i += 1
  164.     end
  165.     endif
  166.     while (1)
  167.     echo ""
  168.     echo -n "Is the disk a SCSI device? [yn] ($scsi): "
  169.     set answer = $<
  170.     if ("$answer" == "" || "$answer" =~ [yn]) break
  171.     echo "Please answer with \"y\" or \"n\""
  172.     end
  173.     if ("$answer" != "") set scsi = "$answer"
  174.  
  175.     if ($handsOff == "n") then
  176.     if ($?SPRITE_OS && $scsi == "y") then
  177.         while (1)
  178.         echo ""
  179.         echo "It is possible to change the disk geometry to maximize"
  180.         echo "disk utilization. This may change the filesystem's idea"
  181.         echo "of the number of heads, sectors, etc. so that they no"
  182.         echo "longer reflect the physical disk geometry. This shouldn't"
  183.         echo "affect performance but may reduce wasted disk space."
  184.         echo -n "Do you want to do this? [yn] ($inventGeometry): "
  185.         set answer = $<
  186.         if ("$answer" == "" || "$answer" =~ [yn]) break
  187.         echo "Please answer with \"y\" or \"n\""
  188.         end
  189.         if ("$answer" != "") set inventGeometry = "$answer"
  190.     endif
  191.     if ($inventGeometry == "n") then
  192.         while (1)
  193.         echo ""
  194.         echo -n "Do you want the disk geometry set from the disktab" \
  195.             "file? [yn] ($disktabGeometry): "
  196.         set answer = $<
  197.         if ("$answer" == "" || "$answer" =~ [yn]) break
  198.         echo "Please answer with \"y\" or \"n\""
  199.         end
  200.         if ("$answer" != "") set disktabGeometry = "$answer"
  201.         if ($disktabGeometry == "y") then
  202.         set repartition = "y"
  203.         endif
  204.     else
  205.         set repartition = "y"
  206.     endif
  207.     if ($repartition != "y") then
  208.         while (1)
  209.         echo ""
  210.         echo -n "Do want to change the disk partitioning? [yn]" \
  211.             "($repartition): "
  212.         set answer = $<
  213.         if ("$answer" == "" || "$answer" =~ [yn]) break
  214.         echo "Please answer with \"y\" or \"n\""
  215.         end
  216.         if ("$answer" != "") set repartition = "$answer"
  217.     else
  218.         echo ""
  219.         echo "If you change the configuration you have to change" \
  220.          "the partitioning."
  221.     endif
  222.     if ($repartition == "y") then
  223.  
  224.         while (1)
  225.         echo ""
  226.         echo -n "Do you want to use the partition information in the" \
  227.             "disktab file? [yn] ($disktabPartition): "
  228.         set answer = $<
  229.         if ("$answer" == "" || "$answer" =~ [yn]) break
  230.         echo "Please answer with \"y\" or \"n\""
  231.         end
  232.         if ("$answer" != "") set disktabPartition = "$answer"
  233.  
  234.         if ($disktabPartition == "n") then
  235.         while (1)
  236.             echo ""
  237.             echo "Please enter the size of each file system as a" \
  238.             "percentage."
  239.             set total = 0
  240.             set i=1
  241.             set sizeString=""
  242.             while ($i <= $numSystems)
  243.             while (1) 
  244.                 echo ""
  245.                 echo -n "Size of file system $i "
  246.                 echo -n "in partition $parts[$i] ($size[$i]): "
  247.                 set answer = $<
  248.                 if ("$answer" == "" ||  \
  249.                 "$answer" =~ [0-9] ||  \
  250.                 "$answer" =~ [0-9][0-9] ||  \
  251.                 "$answer" =~ [0-9][0-9][0-9]) break 
  252.                 echo "Please answer with a number"
  253.             end
  254.             if ("$answer" != "") set size[$i] = "$answer"
  255.             @@ total += $size[$i]
  256.             if ($sizeString != "") then
  257.                 set sizeString = ($sizeString',')
  258.             endif
  259.             set sizeString=($sizeString$parts[$i]':'$size[$i])
  260.             @@ i += 1
  261.             end
  262.             if ($total < 100) then
  263.             while (1)
  264.                 set answer="n"
  265.                 echo ""
  266.                 echo "Warning: the filesystems only use $total" \
  267.                 "percent of the disk."
  268.                 echo -n "Is this OK? [yn] ($answer): "
  269.                 set answer = $<
  270.                 if ("$answer" == "" || "$answer" =~ [yn]) break
  271.                 echo "Please answer with y or n"
  272.             end
  273.             if ("$answer" == "y") then
  274.                 break
  275.             endif
  276.             else if ($total == 100) then
  277.             break
  278.             else
  279.             echo "Sum of sizes cannot be larger than 100"
  280.             endif
  281.         end
  282.         endif
  283.     endif
  284.     endif
  285.     if ($disktabGeometry == "y" || $disktabPartition == "y") then
  286.     while (1)
  287.         echo ""
  288.         echo -n "Enter the name of the disktab file ($disktabFile): "
  289.         set answer = $<
  290.         if ("$answer" != "") set disktabFile = "$answer"
  291.         if (-e $disktabFile) break
  292.         echo "$disktabFile does not exist."
  293.     end
  294.     while (1)
  295.         echo ""
  296.         echo "Enter the type of disk, eg rz55"
  297.         echo -n "This is used to find the info in the disktab ($diskType): "
  298.         set answer = $<
  299.         if ("$answer" != "") set diskType = "$answer"
  300.         if ("$diskType" != "") break
  301.         echo "You must enter a type"
  302.     end
  303.     set diskType = "$answer"
  304.     endif
  305.     if ($disktabGeometry == "y" || $inventGeometry == "y" || \
  306.     $repartition == "y") then
  307.  
  308.     echo ""
  309.     echo -n "Name of raw device, eg rsd00 ($rawDevice): "
  310.     set answer = $<
  311.     if ("$answer" != "") set rawDevice = "$answer"
  312.     endif
  313.     if (! $?SPRITE_OS) then
  314.     while (1)
  315.         echo ""
  316.         echo -n "Do you wish to copy files to the new filesystems? " \
  317.         "[yn] ($doCopy) : "
  318.         set answer = $<
  319.         if ("$answer" == "" || "$answer" =~ [yn]) break
  320.         echo "Please answer with y or n"
  321.     end
  322.     if ("$answer" != "") set doCopy = "$answer"
  323.     endif
  324.     if ($doCopy == "y") then
  325.     set i=1
  326.     while ($i <= $numSystems)
  327.         echo ""
  328.         echo -n "Name of the directory to copy into partition " \
  329.         "$parts[$i] : "
  330.         set answer = $<
  331.         if ("$answer" != "") set copyName[$i] = "$answer"
  332.         @@ i++
  333.     end
  334.     endif
  335.     while (1)
  336.     set answer="n"
  337.     echo ""
  338.     echo "Is the disk going to be installed on a different host"
  339.     echo -n "from the one that is running this script? [yn] ($answer): "
  340.     set answer = $<
  341.     if ("$answer" == "" || "$answer" =~ [yn]) break
  342.     echo "Please answer with y or n"
  343.     end
  344.     if ("$answer" == "y") then
  345.     echo ""
  346.     echo -n "Enter the name or host id of that host: "
  347.     set answer = $<
  348.     if ("$answer" != "") set hostID="$answer"
  349.     set hostID="$answer"
  350.     while (1)
  351.         echo ""
  352.         echo -n "Enter the type of machine [sun3,sun4,sun4c,ds3100]: "
  353.         set answer = $<
  354.         switch("$answer")
  355.         case "sun3"
  356.         case "sun4"
  357.         case "sun4c"
  358.         case "ds3100"
  359.             break
  360.             breaksw
  361.         case ""
  362.             echo "You must enter a machine type"
  363.             breaksw
  364.         default
  365.             echo "Unknown machine type $answer"
  366.             breaksw
  367.         endsw
  368.     end
  369.     set machine="$answer"
  370.     else
  371.     set machine=$MACHINE
  372.     endif
  373.     if ($machine =~ sun*) then
  374.     set labeltype="sun"
  375.     else if ($machine =~ ds*) then
  376.     set labeltype="dec"
  377.     else
  378.     echo "Unknown machine type $machine"
  379.     exit 1
  380.     endif
  381.     while (1)
  382.     echo ""
  383.     echo -n "Are you positively sure you want to" \
  384.             "overwrite the disk? [yn] ($write): "
  385.     set answer = $<
  386.     if ("$answer" == "" || "$answer" =~ [yn]) break
  387.     echo "Please answer with y or n"
  388.     end
  389.     if ("$answer" != "") set write=$answer
  390.     set i=1
  391.     while ($i <= $numSystems)
  392.     set command="$fsmake"
  393.     set command=($command -devDir /dev)
  394.     set command=($command -dev $device -part $parts[$i])
  395.     set command=($command -labeltype $labeltype)
  396.     if ("$copyName[$i]" != "") then
  397.         set command=($command -dir $copyName[$i])
  398.     endif
  399.     if ($scsi == "n") then
  400.         set command=($command -noscsi)
  401.     else
  402.         set command=($command -scsi)
  403.     endif
  404.     if ("$hostID" != "") then
  405.         set command=($command -host $hostID)
  406.     endif
  407.     if ("$diskType" != "") then
  408.         set command=($command -disktype $diskType)
  409.     endif
  410.     if ("$write" != "n") then
  411.         set command=($command -write)
  412.     endif
  413.     if ($i == 1 && "$rawDevice" != "") then
  414.         set command=($command -rawdev $rawDevice)
  415.     endif
  416.     if ($i == 1 && $repartition == "y") then
  417.         set command=($command -repartition)
  418.         if ($disktabPartition == "y") then
  419.         set command=($command -partdisktab)
  420.         set command=($command -disktabName $disktabFile)
  421.         else
  422.         set command=($command -sizes $sizeString)
  423.         endif
  424.     endif
  425.     if ($i == 1 && (($inventGeometry == "y") || \
  426.         ($disktabGeometry == "y"))) then
  427.         set command=($command -reconfig)
  428.         if ($disktabGeometry == "y") then
  429.         set command=($command -configdisktab)
  430.         set command=($command -disktabName $disktabFile)
  431.         endif
  432.     endif
  433.     echo ""
  434.     echo $command
  435.     if (! $?debugFlag) then
  436.         eval $command
  437.         if ($status != 0) then
  438.         echo $fsmake failed
  439.         goto cleanup
  440.         endif
  441.     endif
  442.     @@ i++
  443.     end
  444.  
  445. cleanup:
  446. @
  447.  
  448.  
  449. 1.1
  450. log
  451. @Initial revision
  452. @
  453. text
  454. @d5 1
  455. a5 1
  456. # $Header: /sprite/src/cmds/addhost/RCS/addhost,v 1.10 90/03/07 11:06:42 jhh Exp $ SPRITE (Berkeley)
  457. d347 1
  458. a347 1
  459.     else if ($machine == "ds3100") then
  460. @
  461.